<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import {mapActions, mapGetters} from 'vuex'
import * as user from '@/api/zzdt4j-user'

export default {
  name: 'App',
  computed: {
    ...mapGetters(['tenantInfo'])
  },
  mounted() {
    const userName = this.$cookie.get('userName');
    user
        .getCurrentUser(userName)
        .then((res) => {
          const {resources} = res;
          resources.map((item) => ({
            ...item,
            tenantId: item.resource
          }))
          if (res.role == 'ROLE_ADMIN') {
            resources.unshift({
              action: "rw",
              resources: this.$t('common.allTenant'),
              userName: userName,
              tenantId: this.$t('common.allTenant'),
            })
          }
          this.$store.dispatch('tenant/setTenantList', resources)
          if (!this.tenantInfo.resource) {
            this.$store.dispatch('tenant/setTenantInfo', resources[0])
            console.log("ssss", this.tenantInfo)
          }
        })
        .catch(() => {
        })
  }
}
</script>
